package com.fer.tankr.scenes;

import org.andengine.engine.camera.Camera;
import org.andengine.entity.scene.background.RepeatingSpriteBackground;
import org.andengine.entity.scene.menu.MenuScene;
import org.andengine.entity.scene.menu.item.IMenuItem;
import org.andengine.entity.scene.menu.item.SpriteMenuItem;
import org.andengine.opengl.texture.atlas.bitmap.BitmapTextureAtlas;
import org.andengine.opengl.texture.region.ITextureRegion;
import org.andengine.opengl.vbo.VertexBufferObjectManager;
import com.fer.tankr.AssetManagerImpl;

public class LevelsScene extends MenuScene{
	
	public final static int[] LBLOCKS = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
	public final static int L_LOCK = 0;
	
	public IMenuItem[] lBlocks = new IMenuItem[15];
	
	public BitmapTextureAtlas mBitmapTextureAtlas;
	public RepeatingSpriteBackground mGrassBackground;
	public ITextureRegion grassTexture;
	
	public LevelsScene(Camera camera, VertexBufferObjectManager pVertexBufferObject, AssetManagerImpl assetManager) {
		super(camera);
		setBackground(assetManager.mGrassBackground);
		
		for (int i = 0; i < assetManager.levelImgs.length; i++) {
			lBlocks[i] = new SpriteMenuItem(LBLOCKS[i], assetManager.levelLocked, pVertexBufferObject );
		}
		
		float width = camera.getWidth()/10;
		float height = camera.getHeight()/6;
		float blockWidth = lBlocks[0].getWidth()/2;
		float blockHeight = lBlocks[0].getHeight()/2;
		
		for (int i = 0; i < lBlocks.length; i++) {
			int col = (i+1)%5 == 1 ? 1 : ((i+1)%5 == 2 ? 3 : ((i+1)%5 == 3 ? 5 : ((i+1)%5 == 4 ? 7 : 9)));
			float x = col*width-blockWidth;				
			int row = i+1 <= 5 ? 1 : (i+1 <= 10 ? 3 : 5);
			float y = row*height-blockHeight;
			lBlocks[i].setPosition(x, y);
			addMenuItem(lBlocks[i]);
		}
	}	
}
